package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

public class RecipeTest extends TestCase {
	private Recipe r1;
	
	@Before
	public void setUp() throws Exception {
		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(11);
		r1.setAmtCoffee(15);
		r1.setAmtMilk(15);
		r1.setAmtSugar(15);
		r1.setAmtChocolate(15);
	}

	@Test
	public void testSetInvalidPrice() {
		r1.setPrice(-1);
		assertEquals(r1.getPrice(), 0);
	}
	
	@Test
	public void testGetAmtChocolate() {
		assertEquals(r1.getAmtChocolate(), 15);
	}
	
	@Test
	public void testSetInvalidAmtChocolate() {
		r1.setAmtChocolate(-1);
		assertEquals(r1.getAmtChocolate(), 0);
	}

	@Test
	public void testGetAmtCoffee() {
		assertEquals(r1.getAmtCoffee(), 15);
	}
	
	@Test
	public void testSetInvalidAmtCoffee() {
		r1.setAmtCoffee(-1);
		assertEquals(r1.getAmtCoffee(), 0);
	}

	@Test
	public void testGetAmtMilk() {
		assertEquals(r1.getAmtMilk(), 15);
	}
	
	@Test
	public void testSetInvalidAmtMilk() {
		r1.setAmtMilk(-1);
		assertEquals(r1.getAmtMilk(), 0);
	}

	@Test
	public void testGetAmtSugar() {
		assertEquals(r1.getAmtSugar(), 15);
	}
	
	@Test
	public void testSetInvalidAmtSugar() {
		r1.setAmtSugar(-1);
		assertEquals(r1.getAmtSugar(), 0);
	}

	@Test
	public void testGetName() {
		assertEquals(r1.getName(), "Coffee");
	}

	@Test
	public void testGetPrice() {
		assertEquals(r1.getPrice(), 11);
	}

	@Test
	public void testEqualsRecipe() {
		assertTrue(r1.equals(r1));
	}
	
	@Test
	public void testNotEqualsRecipe() {
		Recipe r2 = new Recipe();
		r2.setName("Hot Chocolate");
		assertFalse(r1.equals(r2));
	}
	
	@Test
	public void testNotEqualsBlankRecipe() {
		assertFalse(r1.equals(new Recipe()));
	}
	
	@Test
	public void testBlankRecipeNotEqualsRecipe() {
		Recipe r2 = new Recipe();
		assertFalse(r2.equals(r1));
	}

	@Test
	public void testToString() {
		assertEquals(r1.toString(), "Coffee");
	}

}
